﻿@model HelloMinasan.Web.Song.ViewModels.TestEntrie
@using HelloMinasan.Resources;
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<div class="contentSectionInside">
    @using (Html.BeginForm())
    {
        if (Model != null && Model.Questions != null && Model.Questions.Any())
        {
        @Html.HiddenFor(x => x.SongId)
        
        
        <div class="contentSection">
            @if (Model.Result != null)
            {
                <div id="popupTestResult">
                    <div class="congratulation" align="center">
                        <img src="@Url.Content("~/Content/Images/congratulation.png")" />
                        <br />
                        You got @Model.Result.Score score(s).<br />
                    </div>
                    @for (int i = 0; i < Model.Questions.Count(); i++)
                    {
                        <div class="testResult">
                            Question @(i + 1) : 
                                                @if (Model.Questions[i].CorrectAnswer == Model.Questions[i].SelectedAnswer)
                                                {
                                                    <font color="green">Correct</font>
                                                }
                                                else
                                                {
                                                    <font color="red">Incorrect</font>
                                                }
                        </div>
                    }
                    <div align="center">
                        <div class="overallPart" align="left">
                            <div class="correctPart" style="width:@Model.Result.CorrectPercent%">&nbsp;</div>
                        </div>
                        @Model.Result.Correct / @Model.Result.Total
                    </div>
                    <a class="buttonClass" href="javascript:location.reload()">Retest</a>

                </div>
            }
            else
            {
                for (int i = 0; i < Model.Questions.Count(); i++)
                {
                <div style="margin-bottom: 15px;">
                    @Html.HiddenFor(x => x.Questions[i].CorrectAnswer)
                    <div class="questionContent">
                        @(i + 1). @Html.HiddenFor(x => x.Questions[i].QuestionContent)
                        @Model.Questions[i].QuestionContent
                    </div>
                    <div class="questionAnswerOption">
                        @Html.HiddenFor(x => x.Questions[i].AnswerA)
                        @Html.RadioButtonFor(x => x.Questions[i].SelectedAnswer, Model.Questions[i].AnswerA)
                        @Html.DisplayFor(x => x.Questions[i].AnswerA)
                    </div>
                    <div class="questionAnswerOption">
                        @Html.HiddenFor(x => x.Questions[i].AnswerB)
                        @Html.RadioButtonFor(x => x.Questions[i].SelectedAnswer, Model.Questions[i].AnswerB)
                        @Html.DisplayFor(x => x.Questions[i].AnswerB)
                    </div>
                    <div class="questionAnswerOption">
                        @Html.HiddenFor(x => x.Questions[i].AnswerC)
                        @Html.RadioButtonFor(x => x.Questions[i].SelectedAnswer, Model.Questions[i].AnswerC)
                        @Html.DisplayFor(x => x.Questions[i].AnswerC)
                    </div>
                    <div class="questionAnswerOption">
                        @Html.HiddenFor(x => x.Questions[i].AnswerD)
                        @Html.RadioButtonFor(x => x.Questions[i].SelectedAnswer, Model.Questions[i].AnswerD)
                        @Html.DisplayFor(x => x.Questions[i].AnswerD)
                    </div>
                </div>
                }
            }
            @if (Model.Result == null)
            {
                <input type="submit" value="Submit" />
            }
        </div>
        }

        else
        {
        <div align="center">
            <img src="@Url.Content("~/Content/Images/trashcan_empty.png")" />
            @Resource.Song_EmptyTest
            @*@Html.ActionLink(" - Return previous song", "Songs", new { id = Model.Song.Id })*@
        </div>
        }
    }
</div>
